package bean;

import entity.Course;
import java.util.*;

public class Teacher extends Person {
    private final List<Course> taughtCourses = new ArrayList<>();

    public Teacher(String id, String name, String gender) {
        super(id, name, gender);
    }

    public Course offerCourse(String courseId, String courseName,
                              String location, String time) {
        Course c = new Course(courseId, courseName, location, time, this.name);
        taughtCourses.add(c);
        System.out.println(name + " 开设了 " + courseName);
        return c;
    }

    @Override
    protected void printDetail() {
        if (taughtCourses.isEmpty()) {
            System.out.println("当前未开课");
            return;
        }
        taughtCourses.forEach(System.out::println);
    }

    public List<Course> getTaughtCourses() {
        return Collections.unmodifiableList(taughtCourses);
    }
}
